import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { OrderCreateDialogComponent } from 'src/app/dialogs/order-create-dialog/order-create-dialog.component';
import { LayoutService } from 'src/app/services/layout.service';
import { OrderService } from 'src/app/services/order.service';

@Component({
    selector: 'app-normal',
    templateUrl: './normal.component.html',
    styleUrls: ['./normal.component.sass'],
})
export class NormalComponent implements OnInit {
    constructor(
        layoutService: LayoutService,
        public orderService: OrderService,
        private matDialog: MatDialog
    ) {
        layoutService.title = '小面馆';
        layoutService.isPremium = false;
    }

    ngOnInit(): void {}

    placeOrders() {
        this.matDialog
            .open(OrderCreateDialogComponent)
            .afterClosed()
            .subscribe((result) => {
                if (result) {
                    this.orderService.placeOrders(result.type, result.count);
                }
            });
    }

    clearOrders() {
        this.orderService.clearOrders();
    }
}
